/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2015-07-29     Arda.Fu      first implementation
 */
#include <rthw.h>
#include <rtdevice.h>
#include <board.h>
#include <rtthread.h>

#define LED0 2 //在 drv_gpio.c 文件 pin_index pins[] 中查到 PC13 编号为 2

 void led_thread_entry(void* parameter)
{
    rt_kprintf("led thread entry!\n");
    // 设置管脚为输出模式
    rt_pin_mode(LED0, PIN_MODE_OUTPUT);

    while (1)
    {
        // 输出低电平，LED0 亮
        rt_pin_write(LED0, PIN_LOW);
        // 挂起 500ms
        rt_thread_delay(rt_tick_from_millisecond(500));
        // 输出高电平，LED0 灭
        rt_pin_write(LED0, PIN_HIGH);
        // 挂起 500ms
        rt_thread_delay(rt_tick_from_millisecond(500));
    }
}

int main(void)
{
    /* user app entry */
    rt_thread_t led_task_tid;
    led_task_tid = rt_thread_create("led", led_thread_entry, RT_NULL, 1024, 3, 10);
    if(led_task_tid != RT_NULL)
    {
        rt_thread_startup(led_task_tid);
    }
    return 0;
}
